using Nop.Admin.Models.Common;
using Nop.Core.Domain.Logistics;
using Nop.Core.Domain.Shipping;
using Nop.Web.Framework;
using Nop.Web.Framework.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Nop.Admin.Models.Logistics
{
    public class LogisticsPackageModel : BaseNopEntityModel
    {
        public LogisticsPackageModel()
        {
            PlanNotes = new List<PlanNoteModel>();
            PackageNotes = new List<PackageNoteModel>();
            AvailablePlanIds = new List<SelectListItem>();
            CustomerAddress = new AddressModel();
        }

        //Identifiers
        [NopResourceDisplayName("Admin.Orders.Shipments.ID")]
        public int ShipmentId { get; set; }

        [NopResourceDisplayName("Admin.Orders.Fields.ID")]
        public int OrderId { get; set; }

        public int? WarehouseId { get; set; }

        public int? ToWarehouseId { get; set; }

        public int PickUpLocationId { get; set; }

        public int DeliveryLocationId { get; set; }

        //Customer info
        [NopResourceDisplayName("Admin.Orders.Fields.Customer")]
        public int CustomerId { get; set; }

        //Time info
        [NopResourceDisplayName("Admin.Logistics.Common.Fields.CreatedOn")]
        public DateTime CreatedOn { get; set; }
        public string CreatedOnStr { get; set; }

        [NopResourceDisplayName("Admin.Logistics.Common.Fields.UpdatedOn")]
        public DateTime? UpdatedOn { get; set; }
        public string UpdatedOnStr { get; set; }

        public string WarehouseAddressString { get; set; }
        public string ToWarehouseAddressString { get; set; }

        public AddressModel CustomerAddress { get; set; }

        //Location info
        public LogisticsLocationModel PickUpLocation { get; set; }
        [NopResourceDisplayName("Admin.Logistics.PickupAddress")]
        public string PickupAddressString { get; set; }
        public int PickupAddressId { get; set; }
        [NopResourceDisplayName("Admin.Logistics.Common.Fields.PZone")]
        public string PickUpZone { get; set; }
        [NopResourceDisplayName("Admin.Logistics.List.PickUpDistrict")]
        public string PickUpDistrict { get; set; }

        public LogisticsLocationModel DeliveryLocation { get; set; }
        [NopResourceDisplayName("Admin.Logistics.DeliveryAddress")]
        public string DeliveryAddressString { get; set; }
        public int DeliveryAddressId { get; set; }
        [NopResourceDisplayName("Admin.Logistics.Common.Fields.DZone")]
        public string DeliveryZone { get; set; }
        [NopResourceDisplayName("Admin.Logistics.List.DeliveryDistrict")]
        public string DeliveryDistrict { get; set; }
        [NopResourceDisplayName("Admin.Logistics.List.DeliveryAttemptCount")]
        public int? DeliveryAttemptCount { get; set; }
        //Google map
        public string PickupAddressGoogleMapsUrl { get; set; }
        public string DeliveryAddressGoogleMapsUrl { get; set; }

        public string ReverseOrder { get; set; }

        #region ToSupportPackageStatusChange

        public SelectList StatusValues { get; set; }

        public bool UpdatePackage { get; set; }

        public bool UpdatePickUpLocation { get; set; }

        public bool UpdateDeliveryLocation { get; set; }

        [NopResourceDisplayName("Admin.Logistics.Packages.StatusUpdateValidForCommission")]
        public bool StatusUpdateValidForCommission { get; set; }

        #endregion

        [NopResourceDisplayName("Admin.Logistics.Common.Fields.Status")]
        public int Status { get; set; }
        [NopResourceDisplayName("Admin.Logistics.Common.Fields.Status")]
        public string StatusName { get; set; }

        public IList<PlanNoteModel> PlanNotes { get; set; }

        public IList<PackageNoteModel> PackageNotes { get; set; }
        public string LatestPackageNoteContent { get; set; }
        public string PackageNoteInput { get; set; }
        public bool AddPackageNoteDisplayToCustomer { get; set; }

        #region PackageDetails

        public decimal? Length { get; set; }
        public decimal? Width { get; set; }
        public decimal? Height { get; set; }

        public decimal? TotalWeight { get; set; }

        public string LinearMeasureUnit { get; set; }
        public string WeightMeasureUnit { get; set; }

        public string Comment { get; set; }

        [NopResourceDisplayName("Admin.Orders.Shipments.TrackingNumber")]
        public string TrackingNumber { get; set; }

        [NopResourceDisplayName("Admin.Logistics.Common.Fields.InsuranceValue")]
        public decimal? InsuranceValue { get; set; }

        public int SpotshubPackageSize { get; set; }
        public int OrderKindId { get; set; }
        #endregion

        #region For Transferring Package between Plans

        [NopResourceDisplayName("Admin.Logistics.Common.Fields.PlanId")]
        public int? PlanId { get; set; }
        [NopResourceDisplayName("Admin.Logistics.Common.Fields.PlanStatusString")]
        public string PlanStatusString { get; set; }

        [NopResourceDisplayName("Admin.Logistics.Packages.SelectedPlanId")]
        public int SelectedPlanId { get; set; }
        public IList<SelectListItem> AvailablePlanIds { get; set; }

        #endregion

        public DateTime? ReadyTime { get; set; }
        [NopResourceDisplayName("Admin.Logistics.Common.Fields.ScheduledPickup")]
        public string ReadyTimeStr { get; set; }

        public DateTime? PickupEndTime { get; set; }
        public string PickupEndTimeStr { get; set; }

        [NopResourceDisplayName("Admin.Logistics.Packages.PickupRank")]
        public int? PickupRank { get; set; }
        [NopResourceDisplayName("Admin.Logistics.Packages.DeliveryRank")]
        public int? DeliveryRank { get; set; }

        [NopResourceDisplayName("Admin.Logistics.Common.Fields.AddOn")]
        public string Attribute { get; set; }
        [NopResourceDisplayName("Admin.Logistics.Common.Fields.Reference")]
        public string Reference { get; set; }

        [NopResourceDisplayName("Admin.Logistics.Common.Fields.PlanDeliveryTimeSpan")]
        public string PlanDeliveryTimeSpan { get; set; }

        public TimeSpan? TimeElapsedSinceOrdered { get; set; }
        public string TimeElapsedSinceOrderedStr { get; set; }
        [NopResourceDisplayName("Admin.Logistics.Common.Fields.ScheduledTime")]
        public string ScheduledTime { get; set; }
    }
}